package com.dst;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dst.entity.User;
import com.dst.mapper.UserMapper;
import com.dst.service.UserService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.util.List;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = UserApplication.class)
public class test {
  @Resource
  private UserMapper userMapper;
  @Resource
  private UserService userService;
  @Test
  public void select(){
    User user = userMapper.selectById(1);
    System.out.println(user);
  }
  @Test
  public void selectLimit(){
    QueryWrapper<User> userQueryWrapper = new QueryWrapper<>();
    QueryWrapper<User> eq = userQueryWrapper.eq("username", "zhangsan").eq("userpassword", "111");
    User user = userMapper.selectOne(eq);
    System.out.println(user);
  }
    @Test
  public void hh1(){
      List<User> list = userService.list();
      for (User user:list
           ) {
        System.out.println(user);
      }
    }
    @Test
  public void hh2(){
      QueryWrapper<User> userQueryWrapper = new QueryWrapper<>();
      QueryWrapper<User> eq = userQueryWrapper.eq("username", "zhan1gsan").eq("userpassword", "111");
      User one = userService.getOne(eq);
      System.out.println(one);
    }
}
